package org.gingresosapi.persistencia;

import org.gingresosapi.beans.Regimenvehiculos;
import java.sql.Date; 
import org.gingresosapi.beans.*;
import org.gingresosapi.controller.*;
import java.io.Serializable;
import java.util.List;
import java.util.ArrayList;
import java.util.*;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.util.Map;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
 import javax.sql.DataSource;
import org.gingresosapi.generales.Mensajeria;
import org.gingresosapi.generales.DataGManager;


/**
*
* @author
*/

public class RegimenvehiculosPersistencia implements Serializable {
private static final long serialVersionUID = 1L;
public static Exception excepcion;
public static boolean esMensaje = false;
public static Connection con = null;
public static java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/gingresosapi/properties/mensajes");
static DataGManager dataGManager;
static List<Regimenvehiculos> list;

public RegimenvehiculosPersistencia(){
         esMensaje =false;
}


/**
*
* insert()
*/

public static boolean insert (Regimenvehiculos regimenvehiculos ) {
  excepcion = null;
  try {
      esMensaje =false;
   
   
   

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pinsert = null;
      String sql = "insert into regimenvehiculos(idvehiculo,idregimen,valor,periodopago,mespago,fechainscripcion,idusuario,fecha,activo,idmunicipio)  values(?,?,?,?,?,?,?,?,?,?)";
      pinsert = con.prepareStatement(sql);
              pinsert.setLong(1,regimenvehiculos.getIdvehiculo());
        pinsert.setString(2,regimenvehiculos.getIdregimen());
        pinsert.setDouble(3,regimenvehiculos.getValor());
        pinsert.setString(4,regimenvehiculos.getPeriodopago());
        pinsert.setString(5,regimenvehiculos.getMespago());
        pinsert.setDate(6,regimenvehiculos.getFechainscripcion());
        pinsert.setString(7,regimenvehiculos.getIdusuario());
        pinsert.setDate(8,regimenvehiculos.getFecha());
        pinsert.setString(9,regimenvehiculos.getActivo());
        pinsert.setString(10,regimenvehiculos.getIdmunicipio());
      int filas= pinsert.executeUpdate();
      pinsert.close();
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
 }


/**
*
* update()
*/

public static boolean update(Regimenvehiculos regimenvehiculos ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update regimenvehiculos set  idvehiculo=?, idregimen=?, valor=?, periodopago=?, mespago=?, fechainscripcion=?, idusuario=?, fecha=?, activo=?, idmunicipio=?  where  idvehiculo ='"+regimenvehiculos.getIdvehiculo()+"' and  idregimen ='"+regimenvehiculos.getIdregimen()+"' and  activo ='"+regimenvehiculos.getActivo()+"' and  idmunicipio ='"+regimenvehiculos.getIdmunicipio()+"'  ";
      pupdate= con.prepareStatement(sql);
      pupdate.setLong(1,regimenvehiculos.getIdvehiculo());
pupdate.setString(2,regimenvehiculos.getIdregimen());
pupdate.setDouble(3,regimenvehiculos.getValor());
pupdate.setString(4,regimenvehiculos.getPeriodopago());
pupdate.setString(5,regimenvehiculos.getMespago());
pupdate.setDate(6,regimenvehiculos.getFechainscripcion());
pupdate.setString(7,regimenvehiculos.getIdusuario());
pupdate.setDate(8,regimenvehiculos.getFecha());
pupdate.setString(9,regimenvehiculos.getActivo());
pupdate.setString(10,regimenvehiculos.getIdmunicipio());
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* update()
*/

public static boolean update(String sqlupdate ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update  regimenvehiculos set " + sqlupdate +"";
      pupdate= con.prepareStatement(sql);
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* updatePrimaryKey()
*/

public static boolean updatePrimaryKey(Regimenvehiculos regimenvehiculos_old , Regimenvehiculos regimenvehiculos) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update regimenvehiculos set  idvehiculo=? ,  idregimen=? ,  activo=? ,  idmunicipio=?  where  idvehiculo ='"+regimenvehiculos_old.getIdvehiculo()+"' and  idregimen ='"+regimenvehiculos_old.getIdregimen()+"' and  activo ='"+regimenvehiculos_old.getActivo()+"' and  idmunicipio ='"+regimenvehiculos_old.getIdmunicipio()+"'  ";
      pupdate= con.prepareStatement(sql);
      pupdate.setLong(1,regimenvehiculos.getIdvehiculo());pupdate.setString(2,regimenvehiculos.getIdregimen());pupdate.setString(9,regimenvehiculos.getActivo());pupdate.setString(10,regimenvehiculos.getIdmunicipio());
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* delete()
*/

public static boolean delete(Regimenvehiculos regimenvehiculos ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from regimenvehiculos  where  idvehiculo = ? and  idregimen = ? and  activo = ? and  idmunicipio = ?  ";
      pdelete= con.prepareStatement(sql);
      pdelete.setLong(1,regimenvehiculos.getIdvehiculo());
pdelete.setString(2,regimenvehiculos.getIdregimen());
pdelete.setString(9,regimenvehiculos.getActivo());
pdelete.setString(10,regimenvehiculos.getIdmunicipio());
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodelete"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* delete()
*/

public static boolean delete(String sqldelete ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from regimenvehiculos where " + sqldelete +"";
      pdelete= con.prepareStatement(sql);
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodelete"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* deleteAll()
*/

public static boolean deleteAll() {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from regimenvehiculos  ";
      pdelete= con.prepareStatement(sql);
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodeleteall"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* exists()
*/



public static boolean exists(Regimenvehiculos regimenvehiculos) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      String sql = "select * from regimenvehiculos where idvehiculo='"+regimenvehiculos.getIdvehiculo()+"' and idregimen='"+regimenvehiculos.getIdregimen()+"' and activo='"+regimenvehiculos.getActivo()+"' and idmunicipio='"+regimenvehiculos.getIdmunicipio()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +" " + bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return false;
   }
    rs.close();
    psquery.close();
 return true;
} catch (Exception ex) {
      excepcion = ex;
}
  return false;
}


/**
*
* findByPrimaryKey()
*/



public static Regimenvehiculos findByPrimaryKey(Regimenvehiculos regimenvehiculos) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
      String sql = "select * from regimenvehiculos where idvehiculo='"+regimenvehiculos.getIdvehiculo()+"' and idregimen='"+regimenvehiculos.getIdregimen()+"' and activo='"+regimenvehiculos.getActivo()+"' and idmunicipio='"+regimenvehiculos.getIdmunicipio()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
            
            
            regimenvehiculos.setIdvehiculo(rs.getLong("idvehiculo"));
regimenvehiculos.setIdregimen(rs.getString("idregimen"));
regimenvehiculos.setValor(rs.getDouble("valor"));
regimenvehiculos.setPeriodopago(rs.getString("periodopago"));
regimenvehiculos.setMespago(rs.getString("mespago"));
regimenvehiculos.setFechainscripcion(rs.getDate("fechainscripcion"));
regimenvehiculos.setIdusuario(rs.getString("idusuario"));
regimenvehiculos.setFecha(rs.getDate("fecha"));
regimenvehiculos.setActivo(rs.getString("activo"));
regimenvehiculos.setIdmunicipio(rs.getString("idmunicipio"));
    }
    rs.close();
    psquery.close();
 return regimenvehiculos;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIdvehiculo()
*/

public static List<Regimenvehiculos> findByIdvehiculo(Regimenvehiculos regimenvehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehiculos>();
      String sql = "select * from regimenvehiculos where idvehiculo='"+regimenvehiculos.getIdvehiculo()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehiculos regimenvehiculos2 = new Regimenvehiculos(
         rs.getLong("idvehiculo"),rs.getString("idregimen"),rs.getDouble("valor"),rs.getString("periodopago"),rs.getString("mespago"),rs.getDate("fechainscripcion"),rs.getString("idusuario"),rs.getDate("fecha"),rs.getString("activo"),rs.getString("idmunicipio"));
            
            
       list.add(regimenvehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIdregimen()
*/

public static List<Regimenvehiculos> findByIdregimen(Regimenvehiculos regimenvehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehiculos>();
      String sql = "select * from regimenvehiculos where idregimen='"+regimenvehiculos.getIdregimen()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehiculos regimenvehiculos2 = new Regimenvehiculos(
         rs.getLong("idvehiculo"),rs.getString("idregimen"),rs.getDouble("valor"),rs.getString("periodopago"),rs.getString("mespago"),rs.getDate("fechainscripcion"),rs.getString("idusuario"),rs.getDate("fecha"),rs.getString("activo"),rs.getString("idmunicipio"));
            
            
       list.add(regimenvehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByValor()
*/

public static List<Regimenvehiculos> findByValor(Regimenvehiculos regimenvehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehiculos>();
      String sql = "select * from regimenvehiculos where valor='"+regimenvehiculos.getValor()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehiculos regimenvehiculos2 = new Regimenvehiculos(
         rs.getLong("idvehiculo"),rs.getString("idregimen"),rs.getDouble("valor"),rs.getString("periodopago"),rs.getString("mespago"),rs.getDate("fechainscripcion"),rs.getString("idusuario"),rs.getDate("fecha"),rs.getString("activo"),rs.getString("idmunicipio"));
            
            
       list.add(regimenvehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByPeriodopago()
*/

public static List<Regimenvehiculos> findByPeriodopago(Regimenvehiculos regimenvehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehiculos>();
      String sql = "select * from regimenvehiculos where periodopago='"+regimenvehiculos.getPeriodopago()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehiculos regimenvehiculos2 = new Regimenvehiculos(
         rs.getLong("idvehiculo"),rs.getString("idregimen"),rs.getDouble("valor"),rs.getString("periodopago"),rs.getString("mespago"),rs.getDate("fechainscripcion"),rs.getString("idusuario"),rs.getDate("fecha"),rs.getString("activo"),rs.getString("idmunicipio"));
            
            
       list.add(regimenvehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByMespago()
*/

public static List<Regimenvehiculos> findByMespago(Regimenvehiculos regimenvehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehiculos>();
      String sql = "select * from regimenvehiculos where mespago='"+regimenvehiculos.getMespago()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehiculos regimenvehiculos2 = new Regimenvehiculos(
         rs.getLong("idvehiculo"),rs.getString("idregimen"),rs.getDouble("valor"),rs.getString("periodopago"),rs.getString("mespago"),rs.getDate("fechainscripcion"),rs.getString("idusuario"),rs.getDate("fecha"),rs.getString("activo"),rs.getString("idmunicipio"));
            
            
       list.add(regimenvehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByFechainscripcion()
*/

public static List<Regimenvehiculos> findByFechainscripcion(Regimenvehiculos regimenvehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehiculos>();
      String sql = "select * from regimenvehiculos where fechainscripcion='"+regimenvehiculos.getFechainscripcion()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehiculos regimenvehiculos2 = new Regimenvehiculos(
         rs.getLong("idvehiculo"),rs.getString("idregimen"),rs.getDouble("valor"),rs.getString("periodopago"),rs.getString("mespago"),rs.getDate("fechainscripcion"),rs.getString("idusuario"),rs.getDate("fecha"),rs.getString("activo"),rs.getString("idmunicipio"));
            
            
       list.add(regimenvehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIdusuario()
*/

public static List<Regimenvehiculos> findByIdusuario(Regimenvehiculos regimenvehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehiculos>();
      String sql = "select * from regimenvehiculos where idusuario='"+regimenvehiculos.getIdusuario()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehiculos regimenvehiculos2 = new Regimenvehiculos(
         rs.getLong("idvehiculo"),rs.getString("idregimen"),rs.getDouble("valor"),rs.getString("periodopago"),rs.getString("mespago"),rs.getDate("fechainscripcion"),rs.getString("idusuario"),rs.getDate("fecha"),rs.getString("activo"),rs.getString("idmunicipio"));
            
            
       list.add(regimenvehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByFecha()
*/

public static List<Regimenvehiculos> findByFecha(Regimenvehiculos regimenvehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehiculos>();
      String sql = "select * from regimenvehiculos where fecha='"+regimenvehiculos.getFecha()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehiculos regimenvehiculos2 = new Regimenvehiculos(
         rs.getLong("idvehiculo"),rs.getString("idregimen"),rs.getDouble("valor"),rs.getString("periodopago"),rs.getString("mespago"),rs.getDate("fechainscripcion"),rs.getString("idusuario"),rs.getDate("fecha"),rs.getString("activo"),rs.getString("idmunicipio"));
            
            
       list.add(regimenvehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByActivo()
*/

public static List<Regimenvehiculos> findByActivo(Regimenvehiculos regimenvehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehiculos>();
      String sql = "select * from regimenvehiculos where activo='"+regimenvehiculos.getActivo()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehiculos regimenvehiculos2 = new Regimenvehiculos(
         rs.getLong("idvehiculo"),rs.getString("idregimen"),rs.getDouble("valor"),rs.getString("periodopago"),rs.getString("mespago"),rs.getDate("fechainscripcion"),rs.getString("idusuario"),rs.getDate("fecha"),rs.getString("activo"),rs.getString("idmunicipio"));
            
            
       list.add(regimenvehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIdmunicipio()
*/

public static List<Regimenvehiculos> findByIdmunicipio(Regimenvehiculos regimenvehiculos,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehiculos>();
      String sql = "select * from regimenvehiculos where idmunicipio='"+regimenvehiculos.getIdmunicipio()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehiculos regimenvehiculos2 = new Regimenvehiculos(
         rs.getLong("idvehiculo"),rs.getString("idregimen"),rs.getDouble("valor"),rs.getString("periodopago"),rs.getString("mespago"),rs.getDate("fechainscripcion"),rs.getString("idusuario"),rs.getDate("fecha"),rs.getString("activo"),rs.getString("idmunicipio"));
            
            
       list.add(regimenvehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* locateByParameters()
*/

public static List<Regimenvehiculos> locateByParameters(Map parametros,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Regimenvehiculos>();
  String sql = "select * from regimenvehiculos";
  if (parametros != null) {
      Iterator it = parametros.entrySet().iterator();
      StringBuilder sb = new StringBuilder("");
      int i = 0;
      while (it.hasNext()) {
          if (i != 0){
            sb.append(" and ");
         }
         i++;
        Map.Entry e = (Map.Entry) it.next();
        sb.append(e.getKey() +"= '"+  e.getValue()+"'");
      }
      if (!sb.toString().equals("")){
         sql = sql + " where " + sb.toString();
      }
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehiculos regimenvehiculos2 = new Regimenvehiculos(
         rs.getLong("idvehiculo"),rs.getString("idregimen"),rs.getDouble("valor"),rs.getString("periodopago"),rs.getString("mespago"),rs.getDate("fechainscripcion"),rs.getString("idusuario"),rs.getDate("fecha"),rs.getString("activo"),rs.getString("idmunicipio"));
            
            
       list.add(regimenvehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* Double fFunc(String funcion, String campo)
*/



public static Double func(String funcion, String campo) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0.0;
  }
      String sql = "select "+funcion+"("+campo+") as contador from regimenvehiculos";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0.0;
   }
    Double tmp =0.0;
   rs.beforeFirst();
   while (rs.next()) {
    tmp =  rs.getDouble("contador");
    }
    rs.close();
    psquery.close();
 return tmp;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0.0;
}


/**
*
* Double func(String funcion, String campo,String where)
*/



public static Double func(String funcion, String campo, String where) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0.0;
  }
      String sql = "select "+funcion+"("+campo+") as contador from regimenvehiculos where "+where +" ";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0.0;
   }
    Double tmp =0.0;
   rs.beforeFirst();
   while (rs.next()) {
    tmp =  rs.getDouble("contador");
    }
    rs.close();
    psquery.close();
 return tmp;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0.0;
}


/**
*
* count()
*/



public static Integer count() {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0;
  }
      String sql = "select count(*) as contador from regimenvehiculos";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0;
   }
   rs.beforeFirst();
   while (rs.next()) {
    x =  rs.getInt("contador");
    }
    rs.close();
    psquery.close();
 return x;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0;
}


/**
*
* count(String sqlquery)
*/



public static Integer count(String sqlquery) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0;
  }
      String sql = "select count(*) as contador from regimenvehiculos where  " + sqlquery +"";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0;
   }
   rs.beforeFirst();
   while (rs.next()) {
    x =  rs.getInt("contador");
    }
    rs.close();
    psquery.close();
 return x;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0;
}


/**
*
* query()
*/

public static List<Regimenvehiculos> query(String query,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
        list = new ArrayList<Regimenvehiculos>();
  String sql = "select * from regimenvehiculos where " + query +"";
  if (query == null || query.equals("")) {
  return null;
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Regimenvehiculos regimenvehiculos2 = new Regimenvehiculos(
         rs.getLong("idvehiculo"),rs.getString("idregimen"),rs.getDouble("valor"),rs.getString("periodopago"),rs.getString("mespago"),rs.getDate("fechainscripcion"),rs.getString("idusuario"),rs.getDate("fecha"),rs.getString("activo"),rs.getString("idmunicipio"));
            
            
       list.add(regimenvehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* getListRecords()
*/

public static List<Regimenvehiculos> getListRecords(Map parametros,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
      list = new ArrayList<Regimenvehiculos>();
  String sql = "select * from regimenvehiculos";
  if (parametros != null) {
      Iterator it = parametros.entrySet().iterator();
      StringBuilder sb = new StringBuilder("");
      while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        sb.append(e.getKey() +"="+  e.getValue());
      }
      if (!sb.toString().equals("")){
         sql = sql + " where " + sb.toString();
      }
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "regimenvehiculos" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
       
        Regimenvehiculos regimenvehiculos2 = new Regimenvehiculos(
         rs.getLong("idvehiculo"),rs.getString("idregimen"),rs.getDouble("valor"),rs.getString("periodopago"),rs.getString("mespago"),rs.getDate("fechainscripcion"),rs.getString("idusuario"),rs.getDate("fecha"),rs.getString("activo"),rs.getString("idmunicipio"));
            
            
       list.add(regimenvehiculos2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
 }


}
